package org.jeecg.config;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.config.sign.interceptor.SignAuthInterceptor;
import org.jeecg.interceptor.ThirdSessionInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.*;

import javax.annotation.Resource;

/**
 * web配置
 */
//@EnableWebMvc
@Configuration
//@Component
@Slf4j
public class WebConfig implements WebMvcConfigurer {
//	public class WebConfig extends WebMvcConfigurerAdapter {
//public class WebConfig extends WebMvcConfigurationSupport {
//	@Resource
//	private RedisUtil redisUtil;

//	@Bean
//	public ThirdSessionInterceptor thirdSessionInterceptor() {
//		return new ThirdSessionInterceptor();
//	}

	@Resource
	private ThirdSessionInterceptor thirdSessionInterceptor;
	/**
	 * 拦截器
	 * @param registry
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		log.info("拦截器---------------");
		/**
		 * 进入ThirdSession拦截器
		 */
		registry
				.addInterceptor(thirdSessionInterceptor)
				.addPathPatterns("/mall-api/**")  //拦截路径
                .excludePathPatterns("/mall-api/wxuser/ma-login","/mall-api/hotel/can-use-hotel-list","/mall-api/hotel/queryById","/mall-api/hotel/can-user-rooms","/mall-api/hotel/room-layout-price");     //不拦截路径
		WebMvcConfigurer.super.addInterceptors(registry);

	}
}
